import {AxiosResponse} from "axios";
import {Result} from "@/types/api-common";
import {LoginHistory} from "@/types/login-history";
import api from "./init";

/**
 * 获取登录历史
 * @returns {Promise<AxiosResponse<Result<LoginHistory[]>>>}
 */
export const getLoginHistory  = (): Promise<AxiosResponse<Result<LoginHistory[]>>> => {
    return api.get("/history/login");
};

/**
 * 删除指定登录历史
 * @param historyId 登录历史ID
 * @returns {Promise<AxiosResponse<Result<any>>>}
 */
export const deleteLoginHistory = (historyId: number): Promise<AxiosResponse<Result<any>>> => {
    return api.delete(`/history/login/delete/${historyId}`);
};

/**
 * 清空所有登录历史
 * @returns {Promise<AxiosResponse<Result<any>>>}
 */
export const clearLoginHistory = (): Promise<AxiosResponse<Result<any>>> => {
    return api.delete("/history/login/clear");
};